package com.tyc.es.controller;

import com.tyc.es.model.ESProperties;
import com.tyc.es.model.Product;
import com.tyc.es.service.ProductService;
import com.tyc.es.utills.HTMLParseUtill;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @Description: java类作用描述
 * @Author: tyc
 * @CreateDate: 2021/1/6 16:16
 */
@RestController
public class TestController {

    @Autowired
    private HTMLParseUtill htmlParseUtill;
    @Autowired
    private ProductService productService;


    @GetMapping("html/test")
    public List<Product> get() throws Exception {
        return htmlParseUtill.parse();
    }

    @GetMapping("/products")
    public boolean addAll() throws Exception {
        List<Product> products = htmlParseUtill.parse();
        boolean flag = productService.insert(products);
        return flag;
    }

    @GetMapping("/es/products")
    public List<Product> getAll() throws Exception {
        productService.getAll(0,10);
        return null;
    }

}
